package com.zll.controller;

import com.zll.dto.ProductDto;
import com.zll.service.ProductService;
import com.zll.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    @PostMapping("/add")
    public JsonResult add(@RequestBody ProductDto productDto) {
        /*try {
            productService.add(productDto);
            return new JsonResult();
        } catch (RuntimeException e) {
            e.printStackTrace();
            return new JsonResult(false,e.getMessage());
        } catch (Exception e) {
            return new JsonResult(false,"操作失败了哦，请稍后重试！");
        }*/

        return productService.add(productDto);
    }

}
